# Replication Archive for "The Dynamics of Refugee Return: Syrian Refugees and Their Migration Intentions"

## Once you download the data from dataverse, please note the following structure of the files and folders. 

## The code files (R files starting with `00--11` as well as `source_cleaning_pca.R` and `source_mean_imputation.R`) are in the base directory.

## Note the following structure for the RAW data files:

- `data/svy.rds` #The Lebanon survey results
- `data/locations.rds` #Locations of primary respondents which will be used to produce the map
- `data/lbn_adm_cdr_20200810/lbn_admbnda_adm*` #Shape files for the map
- `data/jordan.rds` #The Jordan survey results
- `data/hezb_control.rds` #Areas controlled by Hezbollah
- `data/google_maps_travel_distance_output.csv` Travel distance between respondents place of origin in Syria and current residence in Lebanon (at town level)
- `data/baseline_cjt.rds` The Lebanon conjoint results

## We also use the following functions:
- `functions/effect_plotter2.R`
- `functions/effect_plotter3.R`
- `functions/pca_fun.R`
- `functions/plot_it.R`

## The regression tables are all exported to the `tables` folder

## Other tables are exported to the `out` folder

## All figures are exported to the `figures` folder

## Run the files in the following order (they should be in the base directory)

- 00create_directories.R Creates the directors to which results/figures/data will be exported. Note it does not create the directories for the raw data and functions mentioned above. 
- 01mi_parallel.R: conducts parallelized multiple imputation.
	- Note: This file takes several hours on a server
- 02post_mi.R This produces the indices that will be used as predictors, prepares the outcomes and covariates, and produces the scree plots (shown in the appendix)
	- Figures A1-A12 in the appendix
	- Note this loads a source file to conduct the data cleaning
- 03intentions_descriptive.R produces 
	- Figure 1 of the main paper
- 04intentions_drivers.R produces 
	- Figure 2 in main paper
- 05conjoint.R This is the conjoint analysis and produces
	- Figure 3 of the main paper
	- Figure 5 of the main paper	
	- Table A26 in the appendix
- 06jordan_figure.R
	- Figure 4 in the main paper
	- Tables A30-A32

### The rest of the files produce results in the appendix:
- 07appendix_descriptive_stats.R
	- Descriptive tables in the appendix (A7 - A21)
- 08appendix_robustness.R
	- Robustness tests. Produces tables A22 - A25 in the appendix
- 09informationـbootstrap.R. Note, this file takes a few hours to run. It produces the following figures:
	- Figures A13 and A14 in the appendix
	- Note: This file takes several hours on a server
- 10appendix_pROC.R
	- Testing the predictive power--Figures A15-A16 in appendix
	- Note this loads a source file to conduct the cleaning and mean imputation
- 11appendix_push_map.R
	- Produces map in figure A17


## Other:

### We include the codebook for the Lebanon survey inside codebook.xlsx
### The questions in the Jordan data are included in the appendix and the individual answers are inside the code file.


## Software Information:

### With the exceptions below, the entire replication archive was last run on a MacBook Pro running MacOS 11.2.3 (Big Sur) using R version 4.0.5
	- Exceptions: multiple imputation and information bootstrap (which were both run on a server using R version 3.5.1 (2018-07-02) -- "Feather Spray")

### Packages: 
mice_3.13.0
psych_1.9.12
forcats_0.5.1   
stringr_1.4.0   
dplyr_1.0.9     
purrr_0.3.4     
readr_2.1.2     
tidyr_1.2.0     
tibble_3.1.7   
tidyverse_1.3.1 
survey_4.1-1    
survival_3.3-1  
Matrix_1.4-1    
estimatr_1.0.0  
ggthemes_4.2.4  
ggplot2_3.3.6   
foreign_0.8-82 
lubridate_1.8.0
texreg_1.38.6
PRROC_1.3.1
pROC_1.18.0
glmnet_4.1-4
tmap_3.3-3
mapview_2.11.0
tmaptools_3.1-1
sf_1.0-8
raster_3.5-21
sp_1.5-0
spData_2.2.0
haven_2.5.0
survey_4.1-1
